#include "playerskillobject.h"
#include "gamedialogmanager.h"
#include "gamedialog.h"
#include "gamewindow.h"
#include "gametable.h"
#include "player.h"
#include "tileboarditems.h"

/*

  PlayerSkillObject CLASS

*/
PlayerSkillObject::PlayerSkillObject(QObject* parent)
    :QObject(parent)
{
}

/*

  BottomLessSkill CLASS

*/
BottomLessSkill::BottomLessSkill(QObject *parent)
    :PlayerSkillObject(parent)
{
    this->setSkillId(0);
    this->setUseable(true);
    this->setSkillIcon(QPixmap(":/skills/images/BTN_Bottle_Empty.jpg"));
    this->setSkillDesc("Before the move, you may take a Tao token of any color among those available in the supply.");
    this->setSkillName("Bottomless Pocket");
}

void BottomLessSkill::setSkillEffect(GameDialogManager* dm)
{
    dm->askBottomLessBox();
}

/*

  DancePeaksSkill CLASS

*/
DancePeaksSkill::DancePeaksSkill(QObject *parent)
    :PlayerSkillObject(parent)
{
    this->setSkillId(1);
    this->setUseable(false);
    this->setSkillIcon(QPixmap(":/skills/images/boots.JPG"));
    this->setSkillDesc("During your move, you may reach any village tile, not only adjacent ones");
    this->setSkillName("Dance of the Peaks");
}
void DancePeaksSkill::setSkillEffect(GameDialogManager *)
{

}

/*

  TwinWindsSkill CLASS

*/
TwinWindsSkill::TwinWindsSkill(QObject *parent)
    :PlayerSkillObject(parent)
{
    this->setSkillId(2);
    this->setUseable(true);
    this->setSkillIcon(QPixmap(":/skills/images/feixie.jpg"));
    this->setSkillDesc("Before youre move, you may also play one other "
                       "Taoist figurine according to the move rules");
    this->setSkillName("Dance of the Twin Winds");
}

void TwinWindsSkill::setSkillEffect(GameDialogManager *dm)
{
    //show current alive players' heads
    Player* selectPlayer = dm->askPlayerRequestBox(true);
    GameTileRequestDialog* tileDiaRef = dm->getTileRequestDialog();
    CenterTable* cTable = dm->getGameWindow()->getTable()->getCenterTable();

    connect(cTable,SIGNAL(clicked(VillageTile*)),tileDiaRef,SLOT(receiveClickOnTile(VillageTile*)));
    VillageTile* targetVillage = dm->getTileRequestDialog()->execDialog();
    disconnect(cTable, SIGNAL(clicked(VillageTile*)), tileDiaRef, SLOT(receiveClickOnTile(VillageTile*)));

    QPoint* moveDir = selectPlayer->getMoveDistance(targetVillage->getPos());
    //A player can not move more than 2 steps
    if(qAbs(moveDir->x())<2 && qAbs(moveDir->y())<2)
        selectPlayer->setPlayerPos(targetVillage->getPos());
}
